feat: Detect missing slippage validation in DeFi operations - #531
Merged
Conversation
- Created 'defi' module in security rules to group DeFi-related analysis - Implemented 'MissingSlippageValidationRule' to flag swap/liquidity operations lacking slippage protection parameters - Integrated the new rule into the main engine via 'lib.rs' exports - Added comprehensive rustdoc comments explaining the logic and rationale - Added 4 targeted unit tests verifying detection heuristics for missing slippage
|
@TochukwuJustice Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #331
##Summary of changes:
New Feature: Added MissingSlippageValidationRule, which utilizes lexical heuristics to identify DeFi operations (e.g., swap, add_liquidity) and verify that their signatures contain a slippage protection parameter (e.g., min_amount, min_out, limit).
Organization: Created a new defi module inside packages/rules/src/security/ to appropriately categorize DeFi-specific static analysis rules.
Exporting: Updated packages/rules/src/security/mod.rs and packages/rules/src/lib.rs to expose the new rule so it can be utilized by the primary scanning engine.
Testing: Added comprehensive unit tests confirming accurate detection of both protected and unprotected liquidity functions.
##Reason for the changes: Resolves Issue #331. Lack of slippage validation in AMM and DEX contracts leaves user transactions highly vulnerable to MEV sandwich attacks and front-running. This new security rule ensures that developers are proactively warned when critical DeFi operations fail to accept parameters denoting price slippage bounds.